﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NF_Tools
{
    public partial class BF_TextGroup : UserControl
    {
        public BF_TextGroup()
        {
            InitializeComponent();
        }

        [Browsable(true), Category("自定义属性"), Description("组合文本的ID")]
        public int Index { get; set; }

        private string fristText;
        private string lastText;
        private string fristOut;
        private string lastOut;
        private bool saveShow = true;

        [Browsable(true), Category("自定义属性"), Description("第一个文本框的值")]
        public string FristText
        {
            get { return fristText; }
            set 
            { 
                fristText = value;
                if (!string.IsNullOrWhiteSpace(fristText))
                    txtRecommend.Text = fristText;
            }
        }

        [Browsable(true), Category("自定义属性"), Description("第二个文本框的值")]
        public string LastText
        {
            get { return lastText; }
            set 
            {
                lastText = value; 
                if(!string.IsNullOrWhiteSpace(lastText))
                    pF_TextBox1.Text = lastText;
            }
        }

        [Browsable(true), Category("自定义属性"), Description("第一个文本框提示")]
        public string FristOut
        {
            get { return fristOut; }
            set 
            {
                if(!string.IsNullOrWhiteSpace(value))
                    txtRecommend.Pointout = value;
                fristOut = value;
                this.Invalidate();
            }
        }

        [Browsable(true), Category("自定义属性"), Description("第二个文本框提示")]
        public string LastOut
        {
            get { return lastOut; }
            set 
            {
                if (!string.IsNullOrWhiteSpace(value))
                    pF_TextBox1.Pointout = value;
                lastOut = value;
                
            }
        }

        [Browsable(true), Category("自定义属性"), Description("失败显示保存按钮")]
        public bool SaveShow
        {
            get { return saveShow; }
            set 
            { 
                saveShow = value;
                this.picSave.Visible = saveShow;
            }
        }



        /// <summary>
        /// frist
        /// </summary>
        private void txtRecommend_TextChanged(object sender, EventArgs e)
        {
            fristText = txtRecommend.Text.Trim();
        }

        /// <summary>
        /// last
        /// </summary>
        private void pF_TextBox1_TextChanged(object sender, EventArgs e)
        {
            LastText = pF_TextBox1.Text.Trim();
        }





        public delegate void DeleteEventHandle(object sender, EventArgs e);
        public event DeleteEventHandle DeleteEvent;

        [Description("删除事件")]
        private void picDelete_Click(object sender, EventArgs e)
        {
            if(DeleteEvent != null)
                DeleteEvent(this, e);
        }

        public delegate void SaveEventHande(object sender, EventArgs e);
        public event SaveEventHande SaveEvent;

        [Description("保存事件")]
        private void picSave_Click(object sender, EventArgs e)
        {
            if (SaveEvent != null)
                SaveEvent(this, e);
        }






    }
}
